// 引用Mock
// const Mock = require('mockjs');
import mockjs from "mockjs";

const Mock = {
	// 模拟获取订单数据
	// type：订单类型 0为普通订单 1为秒杀订单
	getOrder(type) {
		let array = [];
		const phonePrefix = ['132', '135', '189']
		const index = Math.floor(Math.random() * phonePrefix.length)
		for (let i = 0; i < mockjs.Random.integer(5, 10); i++) {
			array.push(mockjs.mock({
				'name': type == 0 ? '普通订单' : '秒杀订单' + i,
				'price': mockjs.Random.integer(20, 500) + '元',
				'buyer': mockjs.Random.cname(),
				'time': mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'role': mockjs.Random.boolean(),
				'state': mockjs.Random.boolean(),
				'payType': mockjs.Random.boolean(),
				'source': mockjs.Random.url(),
				'phone': phonePrefix[index] + mockjs.mock(/\d{11}/),
			}))
		}
		return array;
	},
	getGoods(type) {
		let name = '';
		if (type == 1) name = '普通商品'
		if (type == 2) name = '秒杀商品'
		if (type == 3) name = '今日推荐'
		let array = [];
		var type = [ '男装','女装','帽子','鞋子' ];
		for (let i = 0; i < mockjs.Random.integer(5, 10); i++) {
			var rand = Math.floor(Math.random() * type.length)
			let color = mockjs.Random.color()
			array.push(mockjs.mock({
				'id':i+1,
				'name': name + i,
				'price': mockjs.Random.integer(20, 500),
				'sold': mockjs.Random.integer(20, 500),
				'inventory': mockjs.Random.integer(20, 500),
				'refund': mockjs.Random.integer(1, 50),
				'intendant': mockjs.Random.cname(),
				'time': mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				"type": type[rand],
				'role': mockjs.Random.boolean(),
				'state': mockjs.Random.boolean(),
				'img': mockjs.Random.image('70x100',`${color}`,'#fff','png','商品示例图')
			}))
		}
		console.log(array);
		return array;
	},
	getManager(){
		let array = [];
		const phonePrefix = ['132', '135', '189']
		const index = Math.floor(Math.random() * phonePrefix.length)
		for(let i = 0; i < mockjs.Random.integer(5,10);i++){
			array.push(mockjs.mock({
				'name':mockjs.Random.cname(),
				'text':mockjs.Random.cparagraph(1),
				'wx':mockjs.Random.string(),
				'state': mockjs.Random.boolean(),
				'revenue':mockjs.Random.integer(10000,500000) + '元',
				'refund':mockjs.Random.integer(50,1000) + '元',
				'source':mockjs.Random.boolean(),
				'client':mockjs.Random.integer(2,100),
				'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'phone': phonePrefix[index] + mockjs.mock(/\d{11}/),
			}))
		}
		return array
	},
	getManagerReq(){
		let array = [];
		for(let i = 0; i < mockjs.Random.integer(5,10);i++){
			array.push(mockjs.mock({
				'text':mockjs.Random.cparagraph(1),
				'state': mockjs.Random.boolean(),
				'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'addtime':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
			}))
		}
		return array
	},
	getManagerDd(){
		let array = [];
		for(let i = 0; i < mockjs.Random.integer(5,10); i++){
			array.push(mockjs.mock({
				'type':'店长订单',
				'name':mockjs.Random.cparagraph(1),
				'ddid':mockjs.Random.string(),
				'manager':mockjs.Random.cname(),
				'number':mockjs.Random.integer(20,500),
				'price':mockjs.Random.integer(500000,5000000),
				'commission':mockjs.Random.integer(5000,50000),
				'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'shipments':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
			}))
		}
		return array
	},
	getTradeInfo(){
		let array = [];
		const phonePrefix = ['132', '135', '189']
		const index = Math.floor(Math.random() * phonePrefix.length)
		for(let i = 0; i < mockjs.Random.integer(5,10); i++){
			array.push(mockjs.mock({
				'name':mockjs.Random.cparagraph(1),
				'id':mockjs.Random.string(),
				'intendant': mockjs.Random.cname(),
				'pay': mockjs.Random.boolean(),
				'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'phone': phonePrefix[index] + mockjs.mock(/\d{11}/),
			}))
		}
		return array;
	},
	getTradeList(){
		let array = [];
		for(let i = 0; i < mockjs.Random.integer(5,10); i++){
			array.push(mockjs.mock({
				'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'price':mockjs.Random.integer(100,5000) + '元',
				'outlay':mockjs.Random.integer(100,5000) + '元',
				'mprice':mockjs.Random.integer(3000,150000) + '元',
				'moutlay':mockjs.Random.integer(3000,150000) + '元',
				'text':mockjs.Random.cparagraph(1),
			}))
		}
		return array
	},
	getDataChart(){
		let array = {
				'money':mockjs.Random.integer(20000,200000),
				'mmoney': mockjs.Random.integer(1000,5000),
				'pmoney':mockjs.Random.integer(2000,10000),
				'user':mockjs.Random.integer(500,1000),
				'fuser':mockjs.Random.integer(10,100)
			};
		return array;
	},
	getDateDay(){
		// let array = [];
		// for(let i = 0; i < mockjs.Random.integer(5,10); i++){
		// 	array.push(mockjs.mock({
		// 		'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
		// 		'money':mockjs.Random.integer(5000,10000),
		// 		'dmoney':mockjs.Random.integer(1000,3000),
		// 		'ymoney':mockjs.Random.integer(1000,3000),
		// 		'dd':mockjs.Random.integer(500,2000),
		// 		'ddd':mockjs.Random.integer(80,250),
		// 		'ydd':mockjs.Random.integer(80,250),
		// 		'person':mockjs.Random.integer(200,600),
		// 		'dperson':mockjs.Random.integer(100,300),
		// 		'yperson':mockjs.Random.integer(100,300),
		// 		'rate':mockjs.Random.integer(50,90),
		// 		'drate':mockjs.Random.integer(20,80),
		// 		'yrate':mockjs.Random.integer(20,80),
		// 		'visitor':mockjs.Random.integer(50000,150000),
		// 		'dvisitor':mockjs.Random.integer(10000,30000),
		// 		'yvisitor':mockjs.Random.integer(10000,30000),
		// 		'frequency':mockjs.Random.integer(500000,1500000),
		// 		'dfrequency':mockjs.Random.integer(100000,300000),
		// 		'yfrequency':mockjs.Random.integer(100000,300000),
		// 		'add':mockjs.Random.integer(250,1000),
		// 		'dadd':mockjs.Random.integer(50,300),
		// 		'yadd':mockjs.Random.integer(50,300),
		// 		'user':mockjs.Random.integer(1000000,3000000),
		// 		'duser':mockjs.Random.integer(100000,300000),
		// 		'yuser':mockjs.Random.integer(100000,300000),
		// 	}))
		// }
		let array ={
				'time':mockjs.Random.datetime('yyyy-MM-dd A HH:mm:ss'),
				'money':mockjs.Random.integer(5000,10000),
				'dmoney':mockjs.Random.integer(1000,3000),
				'ymoney':mockjs.Random.integer(1000,3000),
				'dd':mockjs.Random.integer(500,2000),
				'ddd':mockjs.Random.integer(80,250),
				'ydd':mockjs.Random.integer(80,250),
				'person':mockjs.Random.integer(200,600),
				'dperson':mockjs.Random.integer(100,300),
				'yperson':mockjs.Random.integer(100,300),
				'rate':mockjs.Random.integer(50,90),
				'drate':mockjs.Random.integer(20,80),
				'yrate':mockjs.Random.integer(20,80),
				'visitor':mockjs.Random.integer(50000,150000),
				'dvisitor':mockjs.Random.integer(10000,30000),
				'yvisitor':mockjs.Random.integer(10000,30000),
				'frequency':mockjs.Random.integer(500000,1500000),
				'dfrequency':mockjs.Random.integer(100000,300000),
				'yfrequency':mockjs.Random.integer(100000,300000),
				'add':mockjs.Random.integer(250,1000),
				'dadd':mockjs.Random.integer(50,300),
				'yadd':mockjs.Random.integer(50,300),
				'user':mockjs.Random.integer(1000000,3000000),
				'duser':mockjs.Random.integer(100000,300000),
				'yuser':mockjs.Random.integer(100000,300000),
			};
		return array;
	}
}

export default Mock;
// export const userData = Mock.mock("/data/list","get",{
// 	// 属性 list 的值是一个数组，随机生成1到10个元素
// 	"list|1-10":[
// 		{
// 			//随机生成1-10个星
// 			"string|1-10":"★",
// 			//随机生成1-100之间的任意整数
// 			"number|1-100":1,
// 			// 生成一个浮点数，整数部分大于等于1、小于等于100，小数部分保留1到10位
// 			"floatNumber|1-100.1-10":1,
// 			// 随机生成一个布尔值，值为true的概率是1/2，值为false的概率同样是1/2
// 			"boolean|1":true,
// 			// 随机生成一个布尔值，值为false的概率是2/（2+5），值为true的概率是5/（2+5）
// 			"bool|2-5":false,
// 			// 从属性值 object 中随机选取 2-4 个属性
// 			"object|2-4":{
// 				"310000":"上海市",
// 				"320000":"江苏省",
// 				"330000":"浙江省",
// 				"340000":"安徽省"
// 			},
// 			// 通过重复属性值 array生成一个新数组，重复次数为2
// 			"array|2" : [
// 				"AMC",
// 				"CMD",
// 				"UMC"
// 			],
// 			// 执行函数 function，取其返回值作为最终的属性值，函数的上下文为属性'name'所在的对象
// 			'foo':'哈哈哈哈哈',
// 			'name' : function(){
// 				return this.foo
// 			},
// 			// 根据正则表达式 regexp 反向生成可以匹配它的字符串，用于生成自定义格式的字符串
// 			'regexp' : /\d{5,10}/,
// 		},
// 	],
// 	code : 200,
// 	message : 'ok'
// })